package com.lion.common.modules.file.common.config;

import io.minio.MinioClient;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Chris Chan
 * Create On 2025/8/26 下午5:01
 * Use for: Sample模块配置
 * Explain:
 */
@Configuration
@EnableConfigurationProperties({FileProperties.class})
public class FileModuleConfig {

    @Bean
    @ConditionalOnFileStrategy("minio")
    public MinioClient minioClient(FileProperties fileProperties) {
        return MinioClient.builder()
                .endpoint(fileProperties.getMinio().getEndpoint())
                .credentials(
                        fileProperties.getMinio().getAccessKey(),
                        fileProperties.getMinio().getSecretKey()
                )
                .build();
    }
}
